using System;
using UnityEngine;
using UnityEngine.UI;

public class HomePageItem : MonoBehaviour
{
    public Action<string> action;
    private Text text;
    

    private void Start()
    {
        text = transform.Find("Text").GetComponent<Text>();

        var btn = GetComponent<DoubleClickBtn>();
        btn.onDoubleClick.AddListener(OnBtnClick);
        btn.onPointerEnter += OnPointerEnter;
        btn.onPointerExit += OnPointerExit;
        
        var colors = btn.colors;
        colors.highlightedColor = StaticData.blue;
        btn.colors = colors;
    }

    private void OnPointerEnter()
    {
        text.color = StaticData.blue;
    }

    private void OnPointerExit()
    {
        text.color = Color.white;
    }

    private void OnBtnClick()
    {
        if (action != null)
            action.Invoke(transform.name);
    }
}
